package client;

import java.io.Serializable;

public class ComplaintDetails implements Serializable{

        /**
         * complaint
         */
        public String comp = null;
        /**
         * user id
         */
        private int uid = -1;
        /**
         * complaint id
         */
        private int cid = -1;
        /**
         * complaint status - handled or not
         */
        private int status = -1;
        /**
         * saves details from data base for tables in GUI
         */
        public static Object[][] data = null;
        
        /**
         * 
         * @param uid = user id
         * @param comp = complaint
         */
        public ComplaintDetails(int uid, String comp)
        {
                this.uid = uid;
                this.comp = comp;
        }
        /**
         * 
         * @param details = complaint
         */
        public ComplaintDetails(String details)
        {
                comp = details;
        }
        /**
         * 
         * @param uid = user id
         */
        public void setUid(int uid) {
                this.uid = uid;
        }
        /**
         * 
         * @return user id
         */
        public int getUid() {
                return uid;
        }
        /**
         * 
         * @param cid = complaint id
         */
        public void setCid(int cid) {
                this.cid = cid;
        }
        /**
         * 
         * @return complaint id
         */
        public int getCid() {
                return cid;
        }
        
        public void setStatus(int status) {
                this.status = status;
        }

        public int getStatus() {
                return status;
        }

        public void setComp(String comp) {
                this.comp = comp;
        }

        public String getComp() {
                return comp;
        }
        /**
         * 
         * @param details = complaint details
         * @return complaint details
         */
        public static Object[][] getComplaintDetails(String[] details)
        {
                ObjHandle.sendToServer(details);
                
                if(details[0].equals("get complaints"))
                        data=new Object[((Object[][]) Main.clie.getResult()).length][5];
                else
                        data=new Object[((Object[][]) Main.clie.getResult()).length][3];
            data= (Object[][]) Main.clie.getResult();
                return data;
        }
        /**
         * 
         * @param cid = complaint id
         * @param response = response to complaint
         */
        public static void updateData(String cid,String response)
        {
                String saveResponse[]  = new String[3];
                saveResponse[0] = "Complaint Response";
                saveResponse[1] = cid;
                saveResponse[2] = response;
                
                ObjHandle.sendToServer(saveResponse);
        }
        /**
         * 
         * @param complaint = complaint description
         * @param ID = user id
         * @return = 0 if user doesn't exist, 1 if user exist
         */
        public static int setCompDetail(String complaint, String ID)
        {
                String[] details = new String [3];
                details[0] = "Set Complaint";
                details[1] = complaint;
                details[2] = ID;
                
                ObjHandle.sendToServer(details);
                int a= (Integer) Main.clie.getResult();
                return a;
        }

}